#include "ConditionAnd.h"

ConditionAnd::ConditionAnd(void)
{
}

ConditionAnd::~ConditionAnd(void)
{
}

void	ConditionAnd::AddSimpleCondition	(const ICondition* condition)
{
	this->m_listSimples.push_back(condition);
}

void	ConditionAnd::AddSubCondition		(const ICondition* condition)
{
	this->m_listSub.push_back(condition);
}

bool	ConditionAnd::GetBoolean(void) const
{
	ConditionsVectorConst::const_iterator it    = this->m_listSimples.begin();
	ConditionsVectorConst::const_iterator itEnd = this->m_listSimples.end();
	for (; it != itEnd; ++it)
		if ((*it)->GetBoolean() == false)
			return false;

	it    = this->m_listSub.begin();
	itEnd = this->m_listSub.end();
	for (; it != itEnd; ++it)
		if ((*it)->GetBoolean() == false)
			return false;
	return true;
}

bool	ConditionAnd::ContainsNode(char nodeId) const
{
	ConditionsVectorConst::const_iterator it    = this->m_listSimples.begin();
	ConditionsVectorConst::const_iterator itEnd = this->m_listSimples.end();
	for (; it != itEnd; ++it)
		if ((*it)->ContainsNode(nodeId) == true)
			return true;

	it    = this->m_listSub.begin();
	itEnd = this->m_listSub.end();
	for (; it != itEnd; ++it)
		if ((*it)->ContainsNode(nodeId) == true)
			return true;
	return false;
}